<template>
  <div class="tabs">
    <div class="tabs-title">
      <span>{{ translate('特种(设备)作业人员统计表') }}</span>
      <!-- <span class="count">{{ msgdonecount }}</span>
      <span class="more" @click="moreFn">
        {{ translate('更多') }}
        <vab-icon icon="arrow-drop-right-line" />
      </span> -->
    </div>
    <el-table
              :data="listdonearr"
              style="width: 100%"
              border
              >
      <el-table-column label="序号" type="index" width="55" />
      <el-table-column
        :label="translate('单位名称')"
        prop="UnitName"
      />
      <el-table-column
        :label="translate('合计(人)')"
        prop="HJ"
        width="100px"
      />
      <el-table-column :label="translate('电工作业(人)')" prop="DGZY" width="120px" />
      <el-table-column :label="translate('高处作业(人)')" prop="GCZY" width="120px" />
      <el-table-column :label="translate('特种设备安全管理(人)')" prop="TZSB" />
      <el-table-column :label="translate('起重机指挥(人)')" prop="QZJZH" width="140px" />
      <el-table-column :label="translate('起重机司机(人)')" prop="QZJSJ" width="140px" />
      <el-table-column :label="translate('移动式压力充装(人)')" prop="YDSY" />
      <el-table-column :label="translate('固定式压力容器(人)')" prop="GDSY" />
      <el-table-column :label="translate('锅炉作业(人)')" prop="GLZY" width="120px" />
      <el-table-column :label="translate('锅炉水处理(人)')" prop="GLSCL" width="140px" />
    </el-table>
  </div>
</template>

<script>
  import { translate } from '@/i18n'
  export default defineComponent({
    props: {
      listdonearr: {
        type: Array,
        default: () => {
          return []
        },
      },
      msgdonecount: {
        type: Number,
        default: 0,
      },
    },
    watch: {
      listdonearr() {
        this.getSpanArr()
      },
    },
    data() {
      return {
        tableData: this.listdonearr,
        spanArr: [],
        pos: 0,
      }
    },
    created() {
      this.getSpanArr()
    },
    methods: {
      translate(row) {
        return translate(row)
      },
      getSpanArr() {　
      for (var i = 0; i < this.listdonearr.length; i++) {
            if (i === 0) {
                  this.spanArr.push(1);
                  this.pos = 0
            } else {
              // 判断当前元素与上一个元素是否相同
        if (this.listdonearr[i].SKName === this.listdonearr[i - 1].SKName) {
                    this.spanArr[this.pos] += 1;
                    this.spanArr.push(0);
                  } else {
                    this.spanArr.push(1);
                    this.pos = i;
                  }
            }
        }
    },
      // objectSpanMethod({ row, column, rowIndex, columnIndex }) {
      //   if(columnIndex === 0) {
      //     const _row = this.spanArr[rowIndex];
      //       const _col = _row > 0 ? 1 : 0;
      //       return {
      //             rowspan: _row,
      //             colspan: 1
      //       }
      //   }

      // },
      moreFn() {
        this.$router.push({
          path: '/instancelist',
          query: {
            IsDone: true,
          },
        })
      },
    },
  })
</script>

<style lang="scss" scoped>
  .tabs {
    background: #ffffff;
    padding: 20px;
    .tabs-title {
      position: relative;
      color: #000;
      font-weight: 600;
      padding-bottom: 15px;
      font-size: 20px;

      .more {
        position: absolute;
        top: 0;
        right: 0;
        cursor: pointer;
      }
      .count {
        display: inline-block;
        border: 1px solid #f31434;
        color: red;
        width: 16px;
        height: 16px;
        border-radius: 50%;
        margin-left: 5px;
        text-align: center;
      }
    }
  }
</style>
